<template>
  <view class="agreementPopUpBox">
    <up-popup :show="isShowPrivacy" round="10" mode="center">
      <view class="popup-content" v-if="popUpBoxType == 1">
        <view class="header">
          {{ $t("privacy.personalInformationProtectionTips") }}
        </view>
        <view class="content">
          <view class="content-info">{{ $t("privacy.welcome") }}</view>
          <view class="content-info">
            <!-- 我们将通过 -->
            {{ $t("privacy.weWillPass") }}
            <text class="color-64b" @click="goAgreement('userAgreement', $t('privacy.userAgreement'))">
              《{{ $t("privacy.userAgreement") }}》
            </text>
            <!-- 和 -->
            {{ $t("privacy.and") }}
            <text class="color-64b" @click="
              goAgreement('privacyAgreement', $t('privacy.privacyAgreement'))
              ">
              《{{ $t("privacy.privacyAgreement") }}》
            </text>
            {{ $t("privacy.prompt1") }}
            <!-- 帮助您了解我们为您提供的服务、我们如何处理个人信息以及您享有的权利。我们会严格按照相关法律法规要求，采取各种措施来保护您的个人信息。 -->
          </view>
          <view class="content-info">
            {{ $t("privacy.prompt2") }}
            <!-- 点击“同意”按钮，表示您已知情并同意以上协议，感谢您的理解。 -->
          </view>
        </view>
        <view class="footer">
          <view class="agree" @click="agree">
            {{ $t("privacy.agree") }}
            <!-- 同意 -->
          </view>
          <view class="no-agree" @click="popUpBoxType = 2">
            {{ $t("privacy.noAgree") }}
            <!-- 不同意 -->
          </view>
        </view>
      </view>

      <view class="popup-content" v-if="popUpBoxType == 2">
        <view class="header"> {{ $t("privacy.tips") }} </view>
        <view class="content">
          <view class="content-info">
            <!-- 如果您不同意 -->
            {{ $t("privacy.ifYouDoNotAgree") }}
            <text class="color-64b" @click="goAgreement('userAgreement', $t('privacy.userAgreement'))">《{{
              $t("privacy.userAgreement") }}》
            </text>
            {{ $t("privacy.and") }}
            <text class="color-64b" @click="
              goAgreement('privacyAgreement', $t('privacy.privacyAgreement'))
              ">
              《{{ $t("privacy.privacyAgreement") }}》
            </text>
            ，{{ $t("privacy.regretful") }}
            <!-- 很遗憾我们将无法为您提供服务。您需要同意以上协议后，才能使用智源APP。 -->
          </view>
        </view>
        <view class="footer">
          <view class="agree" @click="agree">
            {{ $t("privacy.agree") }}
            <!-- 同意 -->
          </view>
          <view class="no-agree" @click="quitApp">
            {{ $t("privacy.noAgree") }}
            <!-- 不同意 -->
          </view>
        </view>
      </view>
    </up-popup>
  </view>
</template>

<script>
export default {
  data() {
    return {
      popUpBoxType: 1,
    };
  },
  props: {
    isShowPrivacy: {
      type: Boolean,
      default: () => false,
    },
  },
  computed: {},
  methods: {
    goAgreement(params, name) {
      uni.navigateTo({
        url: `/pages/agreement/agreement?type=${params}&title=${name}`,
      });
    },
    agree() {
      this.$emit("handleAgree", true);
    },
    quitApp() {
      // // #ifdef APP-PLUS
      // plus.ios
      //   .import("UIApplication")
      //   .sharedApplication()
      //   .performSelector("exit");
      // // #endif

      const platform = uni.getSystemInfoSync().platform;
      if (platform === "android") {
        if (typeof plus !== "undefined") {
          plus.runtime.quit();
        } else {
          console.log("当前环境不支持 plus 功能");
        }
      } else if (platform === "ios") {
        plus.runtime.openURL("app-settings:");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.agreementPopUpBox {
  width: 100%;
  max-height: 70vh;
  overflow-y: scroll;

  .popup-content {
    width: 622rpx;
    padding: 60rpx 30rpx;
    box-sizing: border-box;

    .header {
      width: 100%;
      text-align: center;
      font-size: 32rpx;
      font-weight: 500;
      color: #ffffff;
    }

    .content {
      width: 100%;
      text-align: center;
      margin-top: 30rpx;

      .content-info {
        font-size: 28rpx;
        font-weight: normal;
        line-height: 60rpx;
        text-align: center;
        text-transform: uppercase;
        letter-spacing: 0px;
        color: #ffffff;

        .color-64b {
          color: #64b7f6;
        }
      }
    }

    .footer {
      width: 100%;
      margin-top: 60rpx;

      .agree {
        width: 100%;
        height: 88rpx;
        line-height: 88rpx;
        border-radius: 44rpx;
        background: #64b7f6;
        font-size: 32rpx;
        font-weight: 500;
        color: #ffffff;
        text-align: center;
        margin-bottom: 30rpx;
      }

      .no-agree {
        width: 100%;
        height: 88rpx;
        line-height: 88rpx;
        border-radius: 44rpx;
        font-size: 32rpx;
        font-weight: 500;
        color: #ffffff;
        text-align: center;
        border: 1rpx solid #1f3651;
      }
    }
  }
}
</style>
